package bar.dark.lee.select.search;

import java.util.ArrayList;
import java.util.Calendar;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import bar.dark.lee.BDConstents;
import bar.dark.lee.R;
import bar.dark.lee.SuperActivity;
import bar.dark.lee.common.BDUtil;
import bar.dark.lee.common.CalendarPickerDialog;
import bar.dark.lee.common.CheckBoxDialogActivity;
import bar.dark.lee.common.DBSQLite;
import bar.dark.lee.common.DBSQLite.ParseSelectData;
import bar.dark.lee.common.SuperInterface;
import bar.dark.lee.select.SelectActivity;
import bar.dark.lee.setting.TipInfoActivity;
import bar.dark.lee.setting.TipsActivity;

public class SearchActivity extends SuperActivity implements SuperInterface {

	public static final int REQUEST_TYPE = 0;
	public static final int REQUEST_CATEGORY_OUT = 1;
	public static final int REQUEST_CATEGORY_IN = 2;
	public static final int REQUEST_CATEGORY_MOVE = 3;
	public static final int REQUEST_BANKBOOK = 4;
	public static final int REQUEST_CHECKCARD = 5;
	public static final int REQUEST_CREDITCARD = 6;

	public static final String SEARCH_FLAG = "search_flag";
	public static final String SEARCH_TYPE = "search_type";
	public static final String SEARCH_START_DATE = "search_start_date";
	public static final String SEARCH_END_DATE = "search_end_date";
	public static final String SEARCH_CATEGORY_OUT = "search_category_out";
	public static final String SEARCH_CATEGORY_IN = "search_category_in";
	public static final String SEARCH_CATEGORY_MOVE = "search_category_move";
	public static final String SEARCH_BANKBOOK = "search_bankbook";
	public static final String SEARCH_CHECKCARD = "search_checkcard";
	public static final String SEARCH_CREDITCARD = "search_creditcard";
	public static final String SEARCH_MEMO = "search_memo";
	
	private DBSQLite sql;
	
	private View viewType;
	private TextView textType;
	private ImageView imgType;
	private View viewStartDate;
	private TextView TextStartDate;
	private View viewEndDate;
	private TextView TextEndDate;
	private View viewCategoryOut;
	private TextView textCategoryOut;
	private ImageView imgCategoryOut;
	private View viewCategoryIn;
	private TextView textCategoryIn;
	private ImageView imgCategoryIn;
	private View viewCategoryMove;
	private TextView textCategoryMove;
	private ImageView imgCategoryMove;
	private View viewBankBook;
	private TextView textBankBook;
	private ImageView imgBankBook;
	private View viewCheckCard;
	private TextView textCheckCard;
	private ImageView imgCheckCard;
	private View viewCreditCard;
	private TextView textCreditCard;
	private ImageView imgCreditCard;
	private EditText editMemo;
	private Button btnSearch;
	
	private ArrayList<String> listType;
	private ArrayList<String> listTypeSelect;
	private ArrayList<String> listCategoryOut;
	private ArrayList<String> listCategoryOutSelect;
	private ArrayList<String> listCategoryIn;
	private ArrayList<String> listCategoryInSelect;
	private ArrayList<String> listCategoryMove;
	private ArrayList<String> listCategoryMoveSelect;
	private ArrayList<String> listBankBook;
	private ArrayList<String> listBankBookSelect;
	private ArrayList<String> listCheckCard;
	private ArrayList<String> listCheckCardSelect;
	private ArrayList<String> listCreditCard;
	private ArrayList<String> listCreditCardSelect;
	
	private String selectTypeStr;
	
	private int startYear;
	private int startMonth;
	private int startDay;
	
	private int endYear;
	private int endMonth;
	private int endDay;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.search_activity);
		
		setTitle("검색 조회");
		
		sql = DBSQLite.getInstance(this);
		
		setFindView();
		setDataSetting();
		setClickListener();
	}
	
	@Override
	public void setFindView() {
		
		viewType = findViewById(R.id.searchActivity_viewType);
		textType = (TextView) findViewById(R.id.searchActivity_textType);
		imgType = (ImageView) findViewById(R.id.searchActivity_imgType);
		viewStartDate = findViewById(R.id.searchActivity_viewStartDate);
		TextStartDate = (TextView) findViewById(R.id.searchActivity_textStartDate);
		viewEndDate = findViewById(R.id.searchActivity_viewEndDate);
		TextEndDate = (TextView) findViewById(R.id.searchActivity_textEndDate);
		viewCategoryOut = findViewById(R.id.searchActivity_viewCategoryOut);
		textCategoryOut = (TextView) findViewById(R.id.searchActivity_textCategoryOut);
		imgCategoryOut = (ImageView) findViewById(R.id.searchActivity_imgCategoryOut);
		viewCategoryIn = findViewById(R.id.searchActivity_viewCategoryIn);
		textCategoryIn = (TextView) findViewById(R.id.searchActivity_textCategoryIn);
		imgCategoryIn = (ImageView) findViewById(R.id.searchActivity_imgCategoryIn);
		viewCategoryMove = findViewById(R.id.searchActivity_viewCategoryMove);
		textCategoryMove = (TextView) findViewById(R.id.searchActivity_textCategoryMove);
		imgCategoryMove = (ImageView) findViewById(R.id.searchActivity_imgCategoryMove);
		viewBankBook = findViewById(R.id.searchActivity_viewBankBook);
		textBankBook = (TextView) findViewById(R.id.searchActivity_textBankBook);
		imgBankBook = (ImageView) findViewById(R.id.searchActivity_imgBankBook);
		viewCheckCard = findViewById(R.id.searchActivity_viewCheckCard);
		textCheckCard = (TextView) findViewById(R.id.searchActivity_textCheckCard);
		imgCheckCard = (ImageView) findViewById(R.id.searchActivity_imgCheckCard);
		viewCreditCard = findViewById(R.id.searchActivity_viewCreditCard);
		textCreditCard = (TextView) findViewById(R.id.searchActivity_textCreditCard);
		imgCreditCard = (ImageView) findViewById(R.id.searchActivity_imgCreditCard);
		editMemo = (EditText) findViewById(R.id.searchActivity_editMemo);
		btnSearch = (Button) findViewById(R.id.searchActivity_btnSearch);
	}

	@Override
	public void setDataSetting() 
	{
		SharedPreferences pref = getSharedPreferences("pref", Activity.MODE_PRIVATE);
		int startDate = Integer.parseInt(pref.getString(BDConstents.START_DATE, "1"));
		int endDate = startDate - 1;
		
		if (startDate == 1)
		{
			Calendar cal = Calendar.getInstance();
			startYear = cal.get(Calendar.YEAR);
			startMonth = cal.get(Calendar.MONTH);
			startDay = 1;
			
			Calendar cal2 = Calendar.getInstance();
			endYear = cal2.get(Calendar.YEAR);
			endMonth = cal2.get(Calendar.MONTH);
			endDay = cal2.getActualMaximum(Calendar.DAY_OF_MONTH);
		}
		else
		{
			Calendar cal = Calendar.getInstance();
			Calendar cal2 = Calendar.getInstance();
			
			if (startDate > cal.get(Calendar.DAY_OF_MONTH))
			{
				cal.add(Calendar.MONTH, -1);
				
				startYear = cal.get(Calendar.YEAR);
				startMonth = cal.get(Calendar.MONTH);
				startDay = startDate;
				
				endYear = cal2.get(Calendar.YEAR);
				endMonth = cal2.get(Calendar.MONTH);
				endDay = endDate;
			}
			else
			{
				cal2.add(Calendar.MONTH, 1);
				
				startYear = cal.get(Calendar.YEAR);
				startMonth = cal.get(Calendar.MONTH);
				startDay = startDate;
				
				endYear = cal2.get(Calendar.YEAR);
				endMonth = cal2.get(Calendar.MONTH);
				endDay = endDate;
			}
		}
		
		TextEndDate.setText(BDUtil.getDate(endYear, (endMonth+1), endDay));
		
		TextStartDate.setText(BDUtil.getDate(startYear, (startMonth+1), startDay));
		
		listType = new ArrayList<String>();
		listTypeSelect = new ArrayList<String>();
		
		listType.add(BDConstents.REAL_MONEY);
		listType.add(BDConstents.BANK_MONEY);
		listType.add(BDConstents.CHECK_CARD);
		listType.add(BDConstents.CREDIT_CARD);
		listType.add(BDConstents.BANK_TO_REAL);
		listType.add(BDConstents.FAN_MONEY);
		listType.add(BDConstents.REAL_TO_BANK);
		listType.add(BDConstents.MYBANK_INOUT);
		
		sql.selectMapTile(this, "SELECT kind FROM category_out_list ORDER BY count DESC", new ParseSelectData()
		{
			@Override
			public void resultData(Cursor c)
			{
				listCategoryOut = new ArrayList<String>();
				listCategoryOutSelect = new ArrayList<String>();
				
				int nameIndex = c.getColumnIndex("kind");
				c.moveToFirst();
				
				for (int i = 0; i < c.getCount(); i++)
				{
					String kind = c.getString(nameIndex);
					listCategoryOut.add(kind);
					c.moveToNext();
				}
				
				if (listCategoryOut.size() < 1)
				{
					textCategoryOut.setText("목록 없음");
					viewCategoryOut.setClickable(false);
					imgCategoryOut.setVisibility(View.INVISIBLE);
				}
				else
				{
					viewCategoryOut.setClickable(true);
					
					listCategoryOut.add(BDConstents.CATEGORY_USE_CARD);
					listCategoryOut.add(BDConstents.CATEGORY_FAN_OUT_MONEY);
					listCategoryOut.add(BDConstents.CATEGORY_FAN_IN_CHECK);
					listCategoryOut.add(BDConstents.CATEGORY_SUSUMONEY);
					listCategoryOut.add(BDConstents.CATEGORY_POST_OUT);
				}
			}
		});
		
		sql.selectMapTile(this, "SELECT kind FROM category_in_list ORDER BY count DESC", new ParseSelectData()
		{
			@Override
			public void resultData(Cursor c)
			{
				listCategoryIn = new ArrayList<String>();
				listCategoryInSelect = new ArrayList<String>();
				
				int nameIndex = c.getColumnIndex("kind");
				c.moveToFirst();
				
				for (int i = 0; i < c.getCount(); i++)
				{
					String kind = c.getString(nameIndex);
					listCategoryIn.add(kind);
					c.moveToNext();
				}
				
				if (listCategoryIn.size() < 1)
				{
					textCategoryIn.setText("목록 없음");
					viewCategoryIn.setClickable(false);
					imgCategoryIn.setVisibility(View.INVISIBLE);
				}
				else
				{
					viewCategoryIn.setClickable(true);
					
					listCategoryIn.add(BDConstents.CATEGORY_FAN_IN_MONEY);
					listCategoryIn.add(BDConstents.CATEGORY_FAN_OUT_CHECK);
				}
			}
		});
		
		sql.selectMapTile(this, "SELECT kind FROM category_move_list ORDER BY count DESC", new ParseSelectData()
		{
			@Override
			public void resultData(Cursor c)
			{
				listCategoryMove = new ArrayList<String>();
				listCategoryMoveSelect = new ArrayList<String>();
				
				int nameIndex = c.getColumnIndex("kind");
				c.moveToFirst();
				
				for (int i = 0; i < c.getCount(); i++)
				{
					String kind = c.getString(nameIndex);
					listCategoryMove.add(kind);
					c.moveToNext();
				}
				
				if (listCategoryMove.size() < 1)
				{
					textCategoryMove.setText("목록 없음");
					viewCategoryMove.setClickable(false);
					imgCategoryMove.setVisibility(View.INVISIBLE);
				}
				else
				{
					viewCategoryMove.setClickable(true);
					
					listCategoryMove.add(BDConstents.CATEGORY_OUT_CARD);
					listCategoryMove.add(BDConstents.CATEGORY_IN_CARD);
					listCategoryMove.add(BDConstents.CATEGORY_OUT_BANK);
					listCategoryMove.add(BDConstents.CATEGORY_IN_BANK);
				}
			}
		});
		
		sql.selectMapTile(this, "SELECT name FROM bankbook", new ParseSelectData()
		{
			@Override
			public void resultData(Cursor c)
			{
				listBankBook = new ArrayList<String>();
				listBankBookSelect = new ArrayList<String>();
				
				int nameIndex = c.getColumnIndex("name");
				c.moveToFirst();
				
				for (int i = 0; i < c.getCount(); i++)
				{
					String kind = c.getString(nameIndex);
					listBankBook.add(kind);
					c.moveToNext();
				}
				
				if (listBankBook.size() < 1)
				{
					textBankBook.setText("목록 없음");
					viewBankBook.setClickable(false);
					imgBankBook.setVisibility(View.INVISIBLE);
				}
				else
				{
					viewBankBook.setClickable(true);
				}
			}
		});
		
		sql.selectMapTile(this, "SELECT name FROM check_card", new ParseSelectData()
		{
			@Override
			public void resultData(Cursor c)
			{
				listCheckCard = new ArrayList<String>();
				listCheckCardSelect = new ArrayList<String>();
				
				int nameIndex = c.getColumnIndex("name");
				c.moveToFirst();
				
				for (int i = 0; i < c.getCount(); i++)
				{
					String kind = c.getString(nameIndex);
					listCheckCard.add(kind);
					c.moveToNext();
				}
				
				if (listCheckCard.size() < 1)
				{
					textCheckCard.setText("목록 없음");
					viewCheckCard.setClickable(false);
					imgCheckCard.setVisibility(View.INVISIBLE);
				}
				else
				{
					viewCheckCard.setClickable(true);
				}
			}
		});
		
		sql.selectMapTile(this, "SELECT name FROM credit_card", new ParseSelectData()
		{
			@Override
			public void resultData(Cursor c)
			{
				listCreditCard = new ArrayList<String>();
				listCreditCardSelect = new ArrayList<String>();
				
				int nameIndex = c.getColumnIndex("name");
				c.moveToFirst();
				
				for (int i = 0; i < c.getCount(); i++)
				{
					String kind = c.getString(nameIndex);
					listCreditCard.add(kind);
					c.moveToNext();
				}
				
				if (listCreditCard.size() < 1)
				{
					textCreditCard.setText("목록 없음");
					viewCreditCard.setClickable(false);
					imgCreditCard.setVisibility(View.INVISIBLE);
				}
				else
				{
					viewCreditCard.setClickable(true);
				}
			}
		});
	}

	@Override
	public void setClickListener() {
		
		if (listType.size() > 0)
		{
			viewType.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) 
				{
					
					Intent intent = new Intent(superContext, CheckBoxDialogActivity.class);
					intent.putExtra(CheckBoxDialogActivity.CHECKDATA, listType);
					intent.putExtra(CheckBoxDialogActivity.CHECKSELECT, listTypeSelect);
					startActivityForResult(intent, REQUEST_TYPE);
				}
			});
		}
		
		viewStartDate.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
//				DatePickerDialog dialog = new DatePickerDialog(superContext, new OnDateSetListener()
//				{
//					@Override
//					public void onDateSet(DatePicker view, int toYear, int monthOfYear,
//							int dayOfMonth)
//					{
//						String startDate = BDUtil.getDateDB(toYear, monthOfYear+1, dayOfMonth);
//						String endDate = BDUtil.getDateDB(endYear, endMonth+1, endDay);
//						
//						if (Integer.parseInt(startDate) > Integer.parseInt(endDate))
//						{
//							BDUtil.showToast(superContext, "시작날짜 보다 종료날짜가 작을 수는 없습니다.");
//							return;
//						}
//						
//						TextStartDate.setText(BDUtil.getDate(toYear, (monthOfYear+1), dayOfMonth));
//						
//						startYear = toYear;
//						startMonth = monthOfYear;
//						startDay = dayOfMonth;
//					}
//				}, startYear, startMonth, startDay);
//				
//				dialog.show();
				
				CalendarPickerDialog cpd = new CalendarPickerDialog(superContext, new CalendarPickerDialog.ICalendarPickerDateSetListener() {
					@Override
					public void onDateSet(int year, int monthOfYear, int dayOfMonth) {
						
						String startDate = BDUtil.getDateDB(year, monthOfYear+1, dayOfMonth);
						String endDate = BDUtil.getDateDB(endYear, endMonth+1, endDay);
						
						if (Integer.parseInt(startDate) > Integer.parseInt(endDate))
						{
							BDUtil.showToast(superContext, "시작날짜 보다 종료날짜가 작을 수는 없습니다.");
							return;
						}
						
						TextStartDate.setText(BDUtil.getDate(year, (monthOfYear+1), dayOfMonth));
						
						startYear = year;
						startMonth = monthOfYear;
						startDay = dayOfMonth;
						
					}
				}, startYear, startMonth, startDay);
				
				cpd.show();
			}
		});
		
		viewEndDate.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
//				DatePickerDialog dialog = new DatePickerDialog(superContext, new OnDateSetListener()
//				{
//					@Override
//					public void onDateSet(DatePicker view, int toYear, int monthOfYear,
//							int dayOfMonth)
//					{
//						String endDate = BDUtil.getDateDB(toYear, monthOfYear+1, dayOfMonth);
//						String startDate = BDUtil.getDateDB(startYear, startMonth+1, startDay);
//						
//						if (Integer.parseInt(startDate) > Integer.parseInt(endDate))
//						{
//							BDUtil.showToast(superContext, "시작날짜 보다 종료날짜가 작을 수는 없습니다.");
//							return;
//						}
//						
//						TextEndDate.setText(BDUtil.getDate(toYear, (monthOfYear+1), dayOfMonth));
//						
//						endYear = toYear;
//						endMonth = monthOfYear;
//						endDay = dayOfMonth;
//					}
//				}, endYear, endMonth, endDay);
//				
//				dialog.show();
				
				CalendarPickerDialog cpd = new CalendarPickerDialog(superContext, new CalendarPickerDialog.ICalendarPickerDateSetListener() {
					@Override
					public void onDateSet(int year, int monthOfYear, int dayOfMonth) {
						
						String endDate = BDUtil.getDateDB(year, monthOfYear+1, dayOfMonth);
						String startDate = BDUtil.getDateDB(startYear, startMonth+1, startDay);
						
						if (Integer.parseInt(startDate) > Integer.parseInt(endDate))
						{
							BDUtil.showToast(superContext, "시작날짜 보다 종료날짜가 작을 수는 없습니다.");
							return;
						}
						
						TextEndDate.setText(BDUtil.getDate(year, (monthOfYear+1), dayOfMonth));
						
						endYear = year;
						endMonth = monthOfYear;
						endDay = dayOfMonth;
						
					}
				}, endYear, endMonth, endDay);
				
				cpd.show();
			}
		});
		
		if (listCategoryOut.size() > 0)
		{
			viewCategoryOut.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) 
				{
					
					Intent intent = new Intent(superContext, CheckBoxDialogActivity.class);
					intent.putExtra(CheckBoxDialogActivity.CHECKDATA, listCategoryOut);
					intent.putExtra(CheckBoxDialogActivity.CHECKSELECT, listCategoryOutSelect);
					startActivityForResult(intent, REQUEST_CATEGORY_OUT);
				}
			});

		}
		
		if (listCategoryIn.size() > 0)
		{
			viewCategoryIn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) 
				{
					
					Intent intent = new Intent(superContext, CheckBoxDialogActivity.class);
					intent.putExtra(CheckBoxDialogActivity.CHECKDATA, listCategoryIn);
					intent.putExtra(CheckBoxDialogActivity.CHECKSELECT, listCategoryInSelect);
					startActivityForResult(intent, REQUEST_CATEGORY_IN);
				}
			});
		}
		
		if (listCategoryMove.size() > 0)
		{
			viewCategoryMove.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) 
				{
					
					Intent intent = new Intent(superContext, CheckBoxDialogActivity.class);
					intent.putExtra(CheckBoxDialogActivity.CHECKDATA, listCategoryMove);
					intent.putExtra(CheckBoxDialogActivity.CHECKSELECT, listCategoryMoveSelect);
					startActivityForResult(intent, REQUEST_CATEGORY_MOVE);
				}
			});
		}
		
		if (listBankBook.size() > 0)
		{
			viewBankBook.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) 
				{
					Intent intent = new Intent(superContext, CheckBoxDialogActivity.class);
					intent.putExtra(CheckBoxDialogActivity.CHECKDATA, listBankBook);
					intent.putExtra(CheckBoxDialogActivity.CHECKSELECT, listBankBookSelect);
					startActivityForResult(intent, REQUEST_BANKBOOK);
				}
			});
		}
		
		if (listCheckCard.size() > 0)
		{
			viewCheckCard.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) 
				{
					
					Intent intent = new Intent(superContext, CheckBoxDialogActivity.class);
					intent.putExtra(CheckBoxDialogActivity.CHECKDATA, listCheckCard);
					intent.putExtra(CheckBoxDialogActivity.CHECKSELECT, listCheckCardSelect);
					startActivityForResult(intent, REQUEST_CHECKCARD);
				}
			});
		}
		
		if (listCreditCard.size() > 0)
		{
			viewCreditCard.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) 
				{
					
					Intent intent = new Intent(superContext, CheckBoxDialogActivity.class);
					intent.putExtra(CheckBoxDialogActivity.CHECKDATA, listCreditCard);
					intent.putExtra(CheckBoxDialogActivity.CHECKSELECT, listCreditCardSelect);
					startActivityForResult(intent, REQUEST_CREDITCARD);
				}
			});
		}
		
		btnSearch.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(superContext, SelectActivity.class);
				intent.putExtra(SEARCH_FLAG, true);
				intent.putExtra(SEARCH_TYPE, selectTypeStr);
				intent.putExtra(SEARCH_START_DATE, BDUtil.getDateDB(startYear, startMonth+1, startDay));
				intent.putExtra(SEARCH_END_DATE, BDUtil.getDateDB(endYear, endMonth+1, endDay));
				intent.putExtra(SEARCH_CATEGORY_OUT, textCategoryOut.getText().toString());
				intent.putExtra(SEARCH_CATEGORY_IN, textCategoryIn.getText().toString());
				intent.putExtra(SEARCH_CATEGORY_MOVE, textCategoryMove.getText().toString());
				intent.putExtra(SEARCH_BANKBOOK, textBankBook.getText().toString());
				intent.putExtra(SEARCH_CHECKCARD, textCheckCard.getText().toString());
				intent.putExtra(SEARCH_CREDITCARD, textCreditCard.getText().toString());
				intent.putExtra(SEARCH_MEMO, editMemo.getText().toString().trim());
				startActivity(intent);
			}
		});
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		
		if (requestCode == REQUEST_TYPE)
		{
			if (resultCode == Activity.RESULT_OK)
			{
				String selectStr = "";
				selectTypeStr = "";
				
				listTypeSelect.clear();
				
				int [] typeSelect = data.getIntArrayExtra(CheckBoxDialogActivity.CHECKSELECT);
				
				for (int i=0; i<typeSelect.length; i++)
				{
					if (typeSelect[i] == 1)
					{
						switch (i) {
						case 0:
							selectStr += BDConstents.REAL_MONEY + ", ";
							selectTypeStr += i + ", "; 
							listTypeSelect.add("0");
							break;
						case 1:
							selectStr += BDConstents.BANK_MONEY + ", ";
							selectTypeStr += i + ", ";
							listTypeSelect.add("1");
							break;
						case 2:
							selectStr += BDConstents.CHECK_CARD + ", ";
							selectTypeStr += i + ", ";
							listTypeSelect.add("2");
							break;
						case 3:
							selectStr += BDConstents.CREDIT_CARD + ", ";
							selectTypeStr += i + ", ";
							listTypeSelect.add("3");
							break;
						case 4:
							selectStr += BDConstents.BANK_TO_REAL + ", ";
							selectTypeStr += i + ", ";
							listTypeSelect.add("4");
							break;
						case 5:
							selectStr += BDConstents.FAN_MONEY + ", ";
							selectTypeStr += i + ", ";
							listTypeSelect.add("5");
							break;
						case 6:
							selectStr += BDConstents.REAL_TO_BANK + ", ";
							selectTypeStr += i + ", ";
							listTypeSelect.add("6");
							break;
						case 7:
							selectStr += BDConstents.MYBANK_INOUT + ", ";
							selectTypeStr += i + ", ";
							listTypeSelect.add("7");
							break;
						default:
							break;
						}
					}
				}
				
				if (selectStr.length() > 0)
				{
					selectStr = selectStr.trim().substring(0, selectStr.lastIndexOf(","));
					selectTypeStr = selectTypeStr.trim().substring(0, selectTypeStr.lastIndexOf(","));
				}
				else
				{
					selectStr = "조건 없음";
					selectTypeStr = "조건 없음";
				}
				
				textType.setText(selectStr);
			}
		}
		else if (requestCode == REQUEST_CATEGORY_OUT)
		{
			if (resultCode == Activity.RESULT_OK)
			{
				String selectStr = "";
				
				listCategoryOutSelect.clear();
				
				int [] categoryOutSelect = data.getIntArrayExtra(CheckBoxDialogActivity.CHECKSELECT);
				
				for (int i=0; i<categoryOutSelect.length; i++)
				{
					if (categoryOutSelect[i] == 1)
					{
						selectStr += listCategoryOut.get(i) + ", ";
						listCategoryOutSelect.add(i+"");
					}
				}
				
				if (selectStr.length() > 0)
				{
					selectStr = selectStr.trim().substring(0, selectStr.lastIndexOf(","));
				}
				else
				{
					selectStr = "조건 없음";
				}
				
				textCategoryOut.setText(selectStr);
			}
		}
		else if (requestCode == REQUEST_CATEGORY_IN)
		{
			if (resultCode == Activity.RESULT_OK)
			{
				String selectStr = "";
				
				listCategoryInSelect.clear();
				
				int [] categoryInSelect = data.getIntArrayExtra(CheckBoxDialogActivity.CHECKSELECT);
				
				for (int i=0; i<categoryInSelect.length; i++)
				{
					if (categoryInSelect[i] == 1)
					{
						selectStr += listCategoryIn.get(i) + ", ";
						listCategoryInSelect.add(i+"");
					}
				}
				
				if (selectStr.length() > 0)
				{
					selectStr = selectStr.trim().substring(0, selectStr.lastIndexOf(","));
				}
				else
				{
					selectStr = "조건 없음";
				}
				
				textCategoryIn.setText(selectStr);
			}
		}
		else if (requestCode == REQUEST_CATEGORY_MOVE)
		{
			if (resultCode == Activity.RESULT_OK)
			{
				String selectStr = "";
				
				listCategoryMoveSelect.clear();
				
				int [] categoryInSelect = data.getIntArrayExtra(CheckBoxDialogActivity.CHECKSELECT);
				
				for (int i=0; i<categoryInSelect.length; i++)
				{
					if (categoryInSelect[i] == 1)
					{
						selectStr += listCategoryMove.get(i) + ", ";
						listCategoryMoveSelect.add(i+"");
					}
				}
				
				if (selectStr.length() > 0)
				{
					selectStr = selectStr.trim().substring(0, selectStr.lastIndexOf(","));
				}
				else
				{
					selectStr = "조건 없음";
				}
				
				textCategoryMove.setText(selectStr);
			}
		}
		else if (requestCode == REQUEST_BANKBOOK)
		{
			if (resultCode == Activity.RESULT_OK)
			{
				String selectStr = "";
				
				listBankBookSelect.clear();
				
				int [] bankbookSelect = data.getIntArrayExtra(CheckBoxDialogActivity.CHECKSELECT);
				
				for (int i=0; i<bankbookSelect.length; i++)
				{
					if (bankbookSelect[i] == 1)
					{
						selectStr += listBankBook.get(i) + ", ";
						listBankBookSelect.add(i+"");
					}
				}
				
				if (selectStr.length() > 0)
				{
					selectStr = selectStr.trim().substring(0, selectStr.lastIndexOf(","));
				}
				else
				{
					selectStr = "조건 없음";
				}
				
				textBankBook.setText(selectStr);
			}
		}
		else if (requestCode == REQUEST_CHECKCARD)
		{
			if (resultCode == Activity.RESULT_OK)
			{
				String selectStr = "";
				
				listCheckCardSelect.clear();
				
				int [] checkcardSelect = data.getIntArrayExtra(CheckBoxDialogActivity.CHECKSELECT);
				
				for (int i=0; i<checkcardSelect.length; i++)
				{
					if (checkcardSelect[i] == 1)
					{
						selectStr += listCheckCard.get(i) + ", ";
						listCheckCardSelect.add(i+"");
					}
				}
				
				if (selectStr.length() > 0)
				{
					selectStr = selectStr.trim().substring(0, selectStr.lastIndexOf(","));
				}
				else
				{
					selectStr = "조건 없음";
				}
				
				textCheckCard.setText(selectStr);
			}
		}
		else if (requestCode == REQUEST_CREDITCARD)
		{
			if (resultCode == Activity.RESULT_OK)
			{
				String selectStr = "";
				
				listCreditCardSelect.clear();
				
				int [] creditcardSelect = data.getIntArrayExtra(CheckBoxDialogActivity.CHECKSELECT);
				
				for (int i=0; i<creditcardSelect.length; i++)
				{
					if (creditcardSelect[i] == 1)
					{
						selectStr += listCreditCard.get(i) + ", ";
						listCreditCardSelect.add(i+"");
					}
				}
				
				if (selectStr.length() > 0)
				{
					selectStr = selectStr.trim().substring(0, selectStr.lastIndexOf(","));
				}
				else
				{
					selectStr = "조건 없음";
				}
				
				textCreditCard.setText(selectStr);
			}
		}
	}
	
	
	@Override
	protected void tipButton() 
	{
		Intent intent = new Intent(this, TipInfoActivity.class);
		intent.putExtra(TipsActivity.TIP_REQUEST_KEY, TipsActivity.TIP_SELECT);
		startActivity(intent);
	}
}
